<?php
header("Content-Type:json/html;charset=utf8;");
$config = require '../config.php';
$conn = new mysqli($config['servername'], $config['username'], $config['password'], $config['dbname']);
require "../validToken.php";

$info = isValidToken($conn);


if($info['status']){
    $sql = "select id,username,email,address,register_time,type from users ";
    $result = $conn->query($sql);

    $data = array();
    while ($row = $result->fetch_assoc())
    {
        $data[] = $row;
    }
    $result = ['code' =>1, 'data' => $data,  'msg' => "获取用户列表成功!"];
}else{
    $result = ['code' =>0,  'msg' => "权限不足或未登录!"];
}
print_r(json_encode($result));
